#include "pgresult.h"

using namespace Porridge;

PGResult::PGResult(PGresult * res_ = NULL) : res(res_) {}

PGResult::~PGResult()
{
    clear();
}

PGResult& PGResult::operator=(const PGResult &other)
{
    if (this != &other)
    {             
        clear();
        res = other.res;
    }
    return *this;
}

PGResult& PGResult::operator=(PGresult * res_)
{
    if(res != res_) {
        clear();
        res = res_;
    }
    return *this;
}

PGResult::operator PGresult*()
{
    return res;
}

void PGResult::clear()
{
    if(res)
        PQclear(res);
}
